package lzj.example.spring.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

@Slf4j
public class MySpringApplicationRunListener implements SpringApplicationRunListener {

    public MySpringApplicationRunListener(SpringApplication application, String[] args) {
        log.warn("MySpringApplicationRunListener init...");
    }

    @Override
    public void starting() {
        // 开始
        log.warn("starting");
    }

    @Override
    public void environmentPrepared(ConfigurableEnvironment environment) {
        // 准备环境
        log.warn("environmentPrepared");
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        // IOC容器准备完成
        log.warn("contextPrepared");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        // IOC容器加载完成
        log.warn("contextLoaded");
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        log.warn("started");
    }

    @Override
    public void running(ConfigurableApplicationContext context) {
        log.warn("running");
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        log.warn("failed");
    }
}
